# Copyright (c) 2021-2022 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

set(PANDA_BYTECODE_OPT_TESTS_ECMA_LIBRARIES arkbytecodeopt_static arkfile arkbase)
if (NOT (PANDA_TARGET_MOBILE OR PANDA_TARGET_OHOS OR PANDA_ENABLE_FUZZBENCH))
    list(APPEND PANDA_BYTECODE_OPT_TESTS_ECMA_LIBRARIES stdc++fs)
endif()

set(BYTECODE_OPT_TEST_ECMA_SOURCES
    codegen_test_ecmascript.cpp
    reg_encoder_test_ecmascript.cpp
)

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${BYTECODE_OPT_TEST_OPTIONS}")

panda_ecmascript_add_gtest(
    CONTAINS_MAIN
    NAME bytecodeopt_unit_tests_ecma
    SOURCES
        ${BYTECODE_OPT_TEST_ECMA_SOURCES}
    INCLUDE_DIRS
        ${PANDA_ROOT}/bytecode_optimizer/
        ${PANDA_ROOT}/bytecode_optimizer/tests
        ${PANDA_ROOT}
    LIBRARIES
        ${PANDA_BYTECODE_OPT_TESTS_ECMA_LIBRARIES}
    SANITIZERS
        ${PANDA_SANITIZERS_LIST}
)

add_dependencies(bytecode_optimizer_coverage bytecodeopt_unit_tests_ecma)
